var database = require('../../../data/data.js')
Page({
  data: {
    flag: true,
    flag1:false,
    flag2:false,
    flag3:false,
    new_psd:""
  },
  onLoad: function (options) {

  },
  check1: function (e) {
    if (e.detail.value.length != "") {
      this.setData({
        flag1: true
      })
    } else {
      var finish = this.data.finish--;
      this.setData({
        flag1: false
      })
    }
  },
  check2: function (e) {
    if (e.detail.value.length >=6) {
      this.setData({
        new_psd: e.detail.value,
        flag2:true
      })
    } else {
      var finish = this.data.finish--;
      this.setData({
        flag2: false
      })
    }
  },
  check3: function (e) {
    if (e.detail.value == this.data.new_psd) {
      this.setData({
        flag3: true
      })
    } else {
      var finish = this.data.finish--;
      this.setData({
        flag3: false
      })
    }
  },
  submit:function(e){
    var that = this;
    var data = e.detail.value;
    console.log(data.password)
    wx.request({
      url: database.url1 + '/api/V2/user/reset_password',
      data: {
        accessToken: database.accessToken,
        userId: "747A6F7477426E6E59736933622F7649385A773345773D3D",
        password:data.password,
        newpassword: data.new_password1
      },
      method: "POST",
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success(res){
        that.setData({
          status_reason: res.data.status_reason,
          flag:false
        })
      }
    })
  },
  know:function(){
    this.setData({
      flag: true
    })
    if (this.data.status_reason != '密码输入有误，请重新输入密码！'){
      wx.navigateBack({

      })
    }
  }
})